package com.charactereducation.pitchpalace.core.configuration;

import com.charactereducation.pitchpalace.core.interceptor.OneInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created by Baggio on 2019-1-23.
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    private final OneInterceptor oneInterceptor;

    @Autowired
    public InterceptorConfig(OneInterceptor oneInterceptor) {
        this.oneInterceptor = oneInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(oneInterceptor).addPathPatterns("/**");
        registry.addInterceptor(oneInterceptor).excludePathPatterns("/api/**");       //添加不拦截路径
    }
}
